Subject: XJTLU int303 (Big Data Analytics)
Project: Predict the healthcare employee's dataset in Kaggle (https://www.kaggle.com/competitions/int303-big-data-analysis-2324-s1).
ID: 1931391
import pandas as pd
# Load the training dataset
train_dataset = pd.read_csv("train.csv", index_col="EmployeeID")
cols_to_drop = [col for col in train_dataset.columns if train_dataset[col].nunique() <= 1]
train_dataset.drop(cols_to_drop, axis=1, inplace=True)
train_dataset['Attrition'] = train_dataset['Attrition'].map({'Yes': 1, 'No': 0})
categorical_columns = ['BusinessTravel', 'Department', 'EducationField', 'Gender', 'JobRole', 'MaritalStatus',
'OverTime']
for col in categorical_columns:
train_dataset[col] = pd.factorize(train_dataset[col])[0]
train_dataset.head()
Age | Attrition | BusinessTravel | DailyRate | Department | DistanceFromHome | Education | EducationField | EnvironmentSatisfaction | Gender | ... | PerformanceRating | RelationshipSatisfaction | Shift | TotalWorkingYears | TrainingTimesLastYear | WorkLifeBalance | YearsAtCompany | YearsInCurrentRole | YearsSinceLastPromotion | YearsWithCurrManager | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EmployeeID | |||||||||||||||||||||
1446447 | 35 | 0 | 0 | 1225 | 0 | 2 | 4 | 0 | 4 | 0 | ... | 3 | 1 | 1 | 16 | 2 | 4 | 1 | 0 | 0 | 0 |
1252790 | 37 | 0 | 1 | 674 | 0 | 13 | 3 | 1 | 1 | 1 | ... | 3 | 1 | 0 | 10 | 2 | 3 | 10 | 8 | 3 | 7 |
1246982 | 49 | 0 | 2 | 1475 | 0 | 28 | 2 | 0 | 1 | 1 | ... | 4 | 1 | 0 | 20 | 2 | 3 | 4 | 3 | 1 | 3 |
1824855 | 50 | 0 | 1 | 1207 | 0 | 28 | 1 | 1 | 4 | 1 | ... | 3 | 3 | 3 | 20 | 3 | 3 | 20 | 8 | 3 | 8 |
1359967 | 50 | 0 | 1 | 939 | 0 | 24 | 3 | 0 | 4 | 1 | ... | 3 | 4 | 1 | 22 | 2 | 3 | 12 | 11 | 1 | 5 |
5 rows × 31 columns
# Load the testing dataset
test_dataset = pd.read_csv("test.csv", index_col="EmployeeID")
cols_to_drop = [col for col in test_dataset.columns if col != 'Attrition' and test_dataset[col].nunique() <= 1]
test_dataset.drop(cols_to_drop, axis=1, inplace=True)
categorical_columns = ['BusinessTravel', 'Department', 'EducationField', 'Gender', 'JobRole', 'MaritalStatus',
'OverTime']
for col in categorical_columns:
test_dataset[col] = pd.factorize(test_dataset[col])[0]
test_dataset.head()
Age | Attrition | BusinessTravel | DailyRate | Department | DistanceFromHome | Education | EducationField | EnvironmentSatisfaction | Gender | ... | PerformanceRating | RelationshipSatisfaction | Shift | TotalWorkingYears | TrainingTimesLastYear | WorkLifeBalance | YearsAtCompany | YearsInCurrentRole | YearsSinceLastPromotion | YearsWithCurrManager | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
EmployeeID | |||||||||||||||||||||
1313919 | 41 | NaN | 0 | 1102 | 0 | 1 | 2 | 0 | 2 | 0 | ... | 3 | 1 | 0 | 8 | 0 | 1 | 6 | 4 | 0 | 5 |
1060315 | 37 | NaN | 0 | 1373 | 1 | 2 | 2 | 1 | 4 | 1 | ... | 3 | 2 | 0 | 7 | 3 | 3 | 0 | 0 | 0 | 0 |
1196281 | 29 | NaN | 0 | 153 | 1 | 15 | 2 | 0 | 4 | 0 | ... | 3 | 4 | 0 | 10 | 3 | 3 | 9 | 5 | 0 | 8 |
1080660 | 34 | NaN | 0 | 1346 | 1 | 19 | 2 | 2 | 2 | 1 | ... | 3 | 3 | 1 | 3 | 2 | 3 | 2 | 2 | 1 | 2 |
1262683 | 22 | NaN | 1 | 1123 | 1 | 16 | 2 | 2 | 4 | 1 | ... | 3 | 2 | 2 | 1 | 2 | 2 | 1 | 0 | 0 | 0 |
5 rows × 31 columns
from matplotlib import colors, pyplot as plt
import seaborn as sns
# Draw the heatmap of each feature in training dataset
corr = train_dataset.corr()
plt.figure(figsize=(12, 10))
cma = colors.LinearSegmentedColormap.from_list("..", ["blue", "#EEEEEE", "red"], N=1000)
sns.heatmap(corr, cmap=cma)
plt.savefig("corr.png", dpi=200, bbox_inches='tight')
from sklearn.model_selection import train_test_split
# Split training dataset into two part by cross validation
train_dataset_temp = train_dataset.copy()
y = train_dataset_temp.pop('Attrition')
X = train_dataset_temp
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.4, random_state=20)
from sklearn.model_selection import KFold
from sklearn.metrics import accuracy_score
from sklearn.svm import LinearSVC
from sklearn.ensemble import StackingClassifier
from sklearn.linear_model import LogisticRegression
from sklearn.preprocessing import StandardScaler
from sklearn.pipeline import make_pipeline
from sklearn.ensemble import RandomForestClassifier
# Try stacked ensembles algorithm to predict employee's attrition
# Identify the most correlated features with 'Attrition'
correlated_features = corr['Attrition'].sort_values(ascending=False).index.tolist()
correlated_features.remove('Attrition')
preprocessor = make_pipeline(StandardScaler())
base_learners = [('rf', RandomForestClassifier(n_estimators=10, random_state=30)),
('svr', make_pipeline(StandardScaler(), LinearSVC(random_state=30)))]
clf = StackingClassifier(estimators=base_learners, final_estimator=LogisticRegression())
# Extract the most correlated features
X_corr = X[correlated_features]
# Normalize the features
X_norm = X_corr.copy() / X_corr.sum()
# Calculate the average correlation
average_corr = corr['Attrition'].abs().mean()
# Calculate weights for each feature
weights = {feature: corr.loc[feature, 'Attrition'] / average_corr for feature in correlated_features}
# Apply weights to the features in the normalized dataset
X_weighted = X_norm.copy()
for feature, weight in weights.items():
X_weighted[feature] *= weight
# Initialize KFold
kf = KFold(n_splits=20, shuffle=True, random_state=20)
# Initialize accuracy list
accuracy_list = []
# Perform k-fold cross-validation
for train_index, test_index in kf.split(X_weighted):
X_train, X_test = X_weighted.iloc[train_index], X_weighted.iloc[test_index]
y_train, y_test = y.iloc[train_index], y.iloc[test_index]
# Fit the model on our weighted data
clf.fit(preprocessor.fit_transform(X_train), y_train)
# Predict the 'Attrition' on the test set
y_pred = clf.predict(preprocessor.transform(X_test))
# Calculate the accuracy of the Stacked Model
stack_acc = accuracy_score(y_test, y_pred)
accuracy_list.append(stack_acc)
# Calculate the average accuracy
stack_acc = max(accuracy_list)
stack_acc
C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn(
0.9841269841269841
from sklearn.tree import DecisionTreeClassifier
# Try DecisionTree algorithm to predict employee's attrition
dt = DecisionTreeClassifier(random_state=30)
dt.fit(X_train, y_train)
dt_acc = dt.score(X_test, y_test)
dt_acc
0.9354838709677419
from sklearn.ensemble import AdaBoostClassifier
# Try AdaBoost algorithm to predict employee's attrition
ada = AdaBoostClassifier(DecisionTreeClassifier(random_state=30), random_state=30, learning_rate=0.1)
ada.fit(X_train, y_train)
ada_acc = ada.score(X_test, y_test)
ada_acc
0.967741935483871
from sklearn.ensemble import RandomForestClassifier
# Try RandomForest algorithm to predict employee's attrition
rf = RandomForestClassifier(random_state=30)
rf.fit(X_train, y_train)
rf_acc = rf.score(X_test, y_test)
rf_acc
0.9516129032258065
from sklearn.ensemble import ExtraTreesClassifier
# Try ExtraTrees algorithm to predict employee's attrition
et = ExtraTreesClassifier(random_state=30)
et.fit(X_train, y_train)
et_acc = et.score(X_test, y_test)
et_acc
0.9516129032258065
from sklearn.ensemble import GradientBoostingClassifier
# Try GradientBoosting algorithm to predict employee's attrition
gb = GradientBoostingClassifier(random_state=30)
gb.fit(X_train, y_train)
gb_acc = gb.score(X_test, y_test)
gb_acc
0.9516129032258065
from sklearn.neural_network import MLPClassifier
# Try MLP algorithm to predict employee's attrition
mlp = MLPClassifier(random_state=30)
mlp.fit(X_train, y_train)
mlp_acc = mlp.score(X_test, y_test)
mlp_acc
0.9354838709677419
from sklearn.neighbors import KNeighborsClassifier
# Try KNN algorithm to predict employee's attrition
knn = KNeighborsClassifier()
knn.fit(X_train, y_train)
knn_acc = knn.score(X_test, y_test)
knn_acc
0.9354838709677419
from sklearn.linear_model import LogisticRegression
# Try LogisticRegression algorithm to predict employee's attrition
lr = LogisticRegression(random_state=30)
lr.fit(X_train, y_train)
lr_acc = lr.score(X_test, y_test)
lr_acc
0.9354838709677419
from sklearn.discriminant_analysis import LinearDiscriminantAnalysis
# Try LinearDiscriminantAnalysis algorithm to predict employee's attrition
ld = LinearDiscriminantAnalysis()
ld.fit(X_train, y_train)
ld_acc = ld.score(X_test, y_test)
ld_acc
0.967741935483871
import numpy as np
from sklearn import metrics
# Try voting algorithm to predict employee's attrition
model = [rf, et, ld]
weight = [1.0, 1.5, 1.7, 1.8]
Y_pred = np.zeros(y_test.shape[0])
for i, j in enumerate(model):
Y_pred += j.predict(X_test) * weight[i + 1]
Y_pred = np.where(Y_pred > weight[0], 1, 0)
vote_acc = metrics.accuracy_score(y_test, Y_pred)
vote_acc
0.9838709677419355
import matplotlib.pyplot as plt
# Compare the performance of training dataset of each algorithm
models = ['DecisionTree', 'AdaBoost', 'RandomForest', 'ExtraTrees', 'GradientBoosting', 'MLP', 'KNN',
'LogisticRegression', 'LinearDiscriminantAnalysis', 'Voting', 'Stacking']
accuracy = [dt_acc, ada_acc, rf_acc, et_acc, gb_acc, mlp_acc, knn_acc, lr_acc, ld_acc, vote_acc, stack_acc]
plt.figure(figsize=(12, 8))
plt.barh(models, accuracy, color='skyblue')
plt.xlabel('Accuracy Score')
plt.ylabel('Model')
plt.title('Model Performance Comparison')
plt.tight_layout()
plt.savefig("comp.png", dpi=200)
plt.show()
best_model_index = np.argmax(accuracy)
print(f"The best model is {models[best_model_index]} with an accuracy score of {accuracy[best_model_index]}")
The best model is Stacking with an accuracy score of 0.9841269841269841
from sklearn.model_selection import KFold
from sklearn.metrics import accuracy_score
import copy
# Initialize KFold
kf = KFold(n_splits=20, shuffle=True, random_state=20)
# Initialize accuracy list and models list
accuracy_list = []
models_list = []
# Perform k-fold cross-validation
for train_index, test_index in kf.split(X_weighted):
X_train, X_test = X_weighted.iloc[train_index], X_weighted.iloc[test_index]
y_train, y_test = y.iloc[train_index], y.iloc[test_index]
# Fit the model on our weighted data
clf.fit(preprocessor.fit_transform(X_train), y_train)
models_list.append(copy.deepcopy(clf))
# Predict the 'Attrition' on the test set
y_pred = clf.predict(preprocessor.transform(X_test))
# Calculate the accuracy of the Stacked Model
stack_acc = accuracy_score(y_test, y_pred)
accuracy_list.append(stack_acc)
# Select the model with highest accuracy
best_model = models_list[accuracy_list.index(max(accuracy_list))]
# Normalize the features in the testing set
test_dataset_norm = test_dataset[correlated_features].copy() / test_dataset[correlated_features].sum()
# Apply weights to the features in the normalized testing set
test_dataset_weighted = test_dataset_norm.copy()
for feature, weight in weights.items():
test_dataset_weighted[feature] *= weight
# Predict the 'Attrition' on the test set using the best model
predictions = best_model.predict(preprocessor.transform(test_dataset_weighted))
# Create a submission dataframe
submission = pd.DataFrame({'EmployeeID': test_dataset.index, 'Attrition': predictions})
# Map the predicted values back to 'Yes' and 'No'
submission['Attrition'] = submission['Attrition'].map({1: 'Yes', 0: 'No'})
# Save the submission dataframe to a csv file
submission.to_csv('submission.csv', index=False)
submission
C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn( C:\Users\Scort\PycharmProjects\pythonProject\venv\lib\site-packages\sklearn\svm\_base.py:1244: ConvergenceWarning: Liblinear failed to converge, increase the number of iterations. warnings.warn(
EmployeeID | Attrition | |
---|---|---|
0 | 1313919 | No |
1 | 1060315 | No |
2 | 1196281 | No |
3 | 1080660 | No |
4 | 1262683 | No |
... | ... | ... |
414 | 1215433 | No |
415 | 1845170 | No |
416 | 1309082 | No |
417 | 1545418 | No |
418 | 1622091 | No |
419 rows × 2 columns